﻿
using System.Collections.Generic;

namespace ConfClient
{

    /// <summary>
    /// 配置文件
    /// </summary>
    public static partial class Conf
    {
        #region 全局ID EGlobalId
        public static string Value(this EGlobalId GlobalId) => (CfgGlobal[GlobalId].Value);
        public static bool ValueBool(this EGlobalId GlobalId) => (CfgGlobal[GlobalId].ValueBool);
        public static int ValueInt(this EGlobalId GlobalId) => (CfgGlobal[GlobalId].ValueInt);
        public static long ValueLong(this EGlobalId GlobalId) => (CfgGlobal[GlobalId].ValueLong);
        public static float ValueFloat(this EGlobalId GlobalId) => (CfgGlobal[GlobalId].ValueFloat);
        public static List<string> ValueListString(this EGlobalId GlobalId) => (CfgGlobal[GlobalId].ValueListString);
        public static List<int> ValueListInt(this EGlobalId GlobalId) => (CfgGlobal[GlobalId].ValueListInt);
        public static List<float> ValueListfloat(this EGlobalId GlobalId) => (CfgGlobal[GlobalId].ValueListfloat);
        public static List<List<int>> ValueListListInt(this EGlobalId GlobalId) => (CfgGlobal[GlobalId].ValueListListInt);
        #endregion

        #region 返回码 EProtocolResult
        public static bool Success(this EProtocolResult result)
        {
            return result == EProtocolResult.成功;
        }
        #endregion

        #region 多语言字符串
        //获取多语言字符串
        public static string TextLanguage(this string text, ELanguage lang)
        {
            string result = text;
            if (ConfLanguage.TryGetValue(text, out var conf))
            {
                switch (lang)
                {
                    case ELanguage.英语:
                        result = conf.LangEn;
                        break;
                    default:
                        result = conf.LangChs;
                        break;
                }
            }
            if (result == null)
            {
                result = "";
            }
            return result;
        }
        //获取邮件字符串
        public static string TextMail(this EMailText text, ELanguage lang)
        {
            string result = text.ToString();
            if (ConfMailText.TryGetValue((int)text, out var conf))
            {
                switch (lang)
                {
                    case ELanguage.英语:
                        result = conf.LangEn;
                        break;
                    default:
                        result = conf.LangChs;
                        break;
                }
            }
            if (result == null)
            {
                result = "";
            }
            return result;
        }
        // 添加记录
        public static string TextMail(this EMailText text, ELanguage lang, params object[] args)
        {
            return string.Format(text.TextMail(lang), args);
        }
        #endregion


        public static string ColorSp(this ConfigFamily conf)
        {
            return $"#{conf.Color}#";
        }
        public static string ColorName(this ConfigFamily conf)
        {
            return $"#{conf.Color}#{conf.Name}#NOR#";
        }
        public static string ColorName(this ConfigDescLevel conf)
        {
            return $"#{conf.Color}#{conf.Desc}#NOR#";
        }

    }


}
